package com.kx.yooli.kx.wechat.controller.credit;

import com.kx.yooli.kx.wechat.po.result.AjaxResult;
import com.kx.yooli.kx.wechat.service.credit.ICreditService;
import jakarta.annotation.Resource;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Optional;

/**
 * @author john_sqwen-childe.wen
 * date 2024/5/23
 * PROJECT_NAME wechat
 * description create CreditController by john_sqwen
 * and  value is
 */
@RestController
@RequestMapping("/api/credit")
public class CreditController {
    private final Logger log = LoggerFactory.getLogger(CreditController.class);
    @Resource
    private ICreditService iCreditService;
    /**
     * @desction in param idCard query user credit info
     * @param idCard
     * @return json
     */
    @RequestMapping(value = "/queryByIdCard",method = RequestMethod.POST)
    public AjaxResult queryCredit(@RequestParam("mobile") String mobile){
        log.info("in method param value is  :{}",mobile);
        Optional.ofNullable(mobile).orElseThrow();
        return   AjaxResult.success(HttpStatus.OK.name(),iCreditService.selectByIdCard(mobile));
    }
}
